<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<section class="content">
	<div class="box">
		<div class="box-body">
			<sf:form id="ajaxSubmit"
				servletRelativeAction="/manager/borrow/create" method="post"
				modelAttribute="borrowInfo">
				<div class="form-group">
					<label>借款名称:</label>
					<div>
						<sf:input path="name" cssClass="form-control" />
					</div>
				</div>
				<div>
					<label>产品类型：</label>
					<div>
						<sf:select path="product" cssClass="form-control"></sf:select>
					</div>
				</div>
				<div class="form-group">
					<div class="row">
						<div class="col-md-6">
							<label>投资年化率</label>
							<div>
								<sf:input path="investRate" cssClass="form-control" />
							</div>
						</div>
						<div class="col-md-6">
							<label>募资金额:</label>
							<div>
								<sf:input path="totalMoney" cssClass="form-control" />
							</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="row">
						<div class="col-md-6">
							<label>还款期限:</label>
							<div>
								<sf:input path="period" cssClass="form-control" />
							</div>
						</div>
						<div class="col-md-6">
							<label>还款方式</label>
							<div>
								<sf:select path="repaymentMethod" cssClass="form-control">
									<c:forEach items="${repaymentMethods }" var="obj">
										<sf:option value="${obj }">${obj }</sf:option>
									</c:forEach>
								</sf:select>
							</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="row">
					<div class="col-md-6">
						<label>管理费</label>
						<div>
							<sf:input path="managementFee" cssClass="form-control" />
						</div>
						<span class="help-block">如果是0或是空，系统会自动计算管理费</span>
					</div>
					<div class="col-md-6">
						<label>借款人：</label>
						<div>
							<sf:select path="borrower.id" cssClass="form-control">

							</sf:select>
						</div>
					</div>
					</div>
				</div>
				<div>
					<button class="btn btn-primary">确认</button>
				</div>
			</sf:form>
		</div>
	</div>
</section>
<script type="text/javascript">
	$(document).ready(function() {
		$("#ajaxSubmit").submit(function() {
			$.ajax({
				url : $(this).attr("action"),
				data : $(this).serialize(),
				type : 'POST',
				success : function(result) {
					if (result.status == 200) {
						// TODO 成功
					} else {
						// TODO 返回错误
					}
				}
			});
			return false;
		});
	});
</script>